from .contra import bi_contrastive_paraphrase
from utils.data_utils import write_json, read_json

def attack(args, target_texts_path, gen_path, prompts):
    target_texts = read_json(target_texts_path)
    target_texts = target_texts[:len(prompts)] # only attack the first len(prompts) samples

    total_num = len(target_texts)
    print("[INFO] attacking ", total_num, " samples")
    outputs = bi_contrastive_paraphrase(args, target_texts)
    write_json(outputs, gen_path)